<template>
  <NewsEditor ref="newsEditor" type="edit" />
</template>

<script>
import NewsEditor from './components/NewsEditor.vue'
export default {
  name: 'NewsEdit',
  components: {
    NewsEditor
  },
  mounted() {
    console.log(2222)
  },
  beforeRouteLeave(to, from, next) {
    console.log('离开编辑页面去哪: ', to)
    const cachesId = this.$refs.newsEditor.cachesId
    console.log('cachesId为空文章列表就更新: ', cachesId)
    if (to.path === '/news/index' && !cachesId) {
      // 去下级页面时打标记
      to.meta.isFlushed = true
    } else {
      this.$route.meta.isFlushed = false
    }
    next()
  }
}
</script>

<style lang="sass" scoped></style>
